package com.example.roleplay.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.time.Duration;
import java.util.List;

/**
 * 角色扮演应用配置属性
 */
@Data
@Component
@ConfigurationProperties(prefix = "roleplay")
public class RoleplayProperties {

    private Provider provider = new Provider();
    private Asr asr = new Asr();
    private Tts tts = new Tts();
    private Personas personas = new Personas();
    private Knowledge knowledge = new Knowledge();
    private Session session = new Session();
    private ChatGLM chatglm = new ChatGLM();
    private Zhipu zhipu = new Zhipu();

    @Data
    public static class Provider {
        private String llm = "chatglm";
        private String asr = "whisper";
        private String tts = "coqui";
    }

    @Data
    public static class Asr {
        private String baseUrl = "http://localhost:9000";
        private Duration timeout = Duration.ofSeconds(30);
        private List<String> supportedFormats = List.of("wav", "mp3", "m4a");
    }

    @Data
    public static class Tts {
        private String baseUrl = "http://localhost:8000";
        private Duration timeout = Duration.ofSeconds(30);
        private String defaultVoice = "jenny";
        private List<String> supportedVoices = List.of("jenny", "ryan", "adam", "nova");
    }

    @Data
    public static class Personas {
        private String dataPath = "classpath:personas/";
        private boolean dynamicLoading = true;
    }

    @Data
    public static class Knowledge {
        private String snippetsPath = "classpath:snippets/";
        private double similarityThreshold = 0.3;
        private int maxResults = 3;
    }

    @Data
    public static class Session {
        private int timeoutMinutes = 30;
        private int maxMemoryTurns = 10;
        private int maxConcurrentSessions = 1000;
    }

    @Data
    public static class ChatGLM {
        private String apiKey = "your-chatglm-api-key-here";
        private String baseUrl = "https://open.bigmodel.cn/api/paas/v4";
        private String model = "glm-4-flash";
        private double temperature = 0.7;
        private int maxTokens = 1000;
        private Duration timeout = Duration.ofSeconds(30);
    }

    @Data
    public static class Zhipu {
        private String apiKey = "your-zhipu-api-key-here";
        private String baseUrl = "https://open.bigmodel.cn/api/paas/v4";
        private ZhipuAsr asr = new ZhipuAsr();
        private ZhipuTts tts = new ZhipuTts();
        
        @Data
        public static class ZhipuAsr {
            private String model = "glm-asr";
            private Duration timeout = Duration.ofSeconds(30);
            private List<String> supportedFormats = List.of("wav", "mp3", "m4a", "flac");
        }
        
        @Data
        public static class ZhipuTts {
            private String model = "cogtts";
            private String voice = "female";
            private double speed = 1.0;
            private double volume = 1.0;
            private String responseFormat = "mp3";
            private String encodeFormat = "base64";
            private boolean stream = true;
            private Duration timeout = Duration.ofSeconds(30);
            private List<String> supportedVoices = List.of("female", "male", "彤彤", "小陈", "锤锤", "jam", "kazi", "douji", "luodo");
        }
    }
}